package com.ruoyi.web.controller.patent;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.domain.TycPatent;


import com.ruoyi.domain.YcPersonal;
import com.ruoyi.service.ITycPatentService;

import com.ruoyi.service.IYcPersonalService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 专利Controller
 * 
 * @author ruoyi
 * @date 2020-09-09
 */
@Controller
@RequestMapping("/ruoyi/patentexa")
public class TycPatentExaController extends BaseController
{
    private String prefix = "ruoyi/patentexa";

    @Autowired
    private ITycPatentService tycPatentService;

    @Resource
    private IYcPersonalService iYcPersonalService;
    @RequiresPermissions("ruoyi:patentexa:view")
    @GetMapping()
    public String patent()
    {
        return prefix + "/patentexa";
    }

    /**
     * 管理员看到的页面
     */
    @RequiresPermissions("ruoyi:patentexa:listadmin")
    @PostMapping("/admin")
    @ResponseBody
    public TableDataInfo admin(TycPatent tycPatent) {
        startPage();
        //管理员只能看到待审批和审批通过的,已备案,待备案 驳回或者撤回的将看不到
        List<TycPatent> list = tycPatentService.selectYcTaskListAdmin(tycPatent);
        return getDataTable(list);
    }

    /**
     * 驳回备案
     */
    @RequiresPermissions("ruoyi:patentexa:refusal")
    @Log(title = "审批状态", businessType = BusinessType.UPDATE)
    @PostMapping("/refusal")
    @ResponseBody
    public AjaxResult refusal(Long id) {
        //更新备案为驳回备案
        tycPatentService.refusal(id);
        return success();
    }


    /**
     * 通过备案
     */
    @RequiresPermissions("ruoyi:patentexa:consent")
    @Log(title = "审批状态", businessType = BusinessType.UPDATE)
    @PostMapping("/consent")
    @ResponseBody
    public AjaxResult consent(Long id) {
        //更新备案状态为已备案
        tycPatentService.consent(id);
        return success();
    }


    /**
     * 通过审批
     */
    @RequiresPermissions("ruoyi:patentexa:beApproved")
    @Log(title = "审批状态", businessType = BusinessType.UPDATE)
    @PostMapping("/beApproved")
    @ResponseBody
    public AjaxResult beApproved(Long id) {
        //更新审批状态为已通过
        tycPatentService.updateBeApproved(id);
        return success();
    }


    /**
     * 驳回审批
     */
    @RequiresPermissions("ruoyi:patentexa:dismissTheApproval")
    @Log(title = "审批状态", businessType = BusinessType.UPDATE)
    @PostMapping("/dismissTheApproval")
    @ResponseBody
    public AjaxResult dismissTheApproval(Long id) {
        //更新审批状态为驳回
        tycPatentService.updateDismissTheApproval(id);
        return success();
    }
    /**
     *
     */
    @RequiresPermissions("system:dict:list")
    @GetMapping("/chakan/{userId}")
    public String chakan(@PathVariable("userId") Long userId, ModelMap mmap)
    {
        YcPersonal ycPersonal = iYcPersonalService.selectYcPersonalById(userId);
        System.out.println(ycPersonal);
        mmap.put("ycPersonal", ycPersonal);
        return prefix + "/particularss";
    }


}
